<?php
/* @var $this SliderController */
/* @var $model Slider */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'slider-_Slider-form',
        'enableAjaxValidation' => FALSE,
  'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>


    <?php echo $form->errorSummary($model); ?>

    <div class="form_left">
        <?php echo $form->labelEx($model, 'title'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'title', array('size' => 40, 'maxlength' => 200, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'title'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'url'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textArea($model, 'url', array('style' => 'width: 400px; height: 100px;','size' => 70, 'maxlength' => 1000, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'url'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'photo'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->fileField($model, 'photo', array('size' => 40, 'maxlength' => 50)); ?>
        <?php echo $form->error($model, 'photo'); ?>
    </div>
    <div class="clear"></div>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'dateExpend'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'dateExpend', array('class' => 'easyui-datebox', 'data-options' => 'formatter:myformatter,parser:myparser')); ?>
        <?php echo $form->error($model, 'dateExpend'); ?>
    </div>

    <div class="clear"></div>

    <div class="form_left">
        <?php echo $form->labelEx($model, 'small_content'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textArea($model, 'small_content', array('style' => 'width: 400px; height: 100px;', 'maxlength' => 300, 'required' => 'required')); ?>
        <?php echo $form->error($model, 'small_content'); ?>
    </div>
    <div class="clear"></div>
     <?php
    $session = new CHttpSession;
    $session->open();
    if ($session['user_salesmart'][1] > 98) {
        ?>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'position'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->textField($model, 'position', array('class' => 'easyui-numberspinner', 'style' => 'width:80px;')); ?>
        <?php echo $form->error($model, 'position'); ?>
    </div>
    <div class="clear"></div>
    <?php }?>
    <div class="form_left">
        <?php echo $form->labelEx($model, 'type'); ?>
    </div>
    <div class="form_right">
        <?php echo $form->dropDownList($model, 'type', array('0' => 'Quảng cáo tin tức', '1' => 'Quảng cáo video')); ?>
        <?php echo $form->error($model, 'type'); ?>
    </div>

    <div class="clear"></div>
    <div class="form_left">.</div>
    <div class="row buttons">
        <?php echo CHtml::submitButton('Cập nhật'); ?>
    </div>

    <?php $this->endWidget(); ?>
<script type="text/javascript">
    function myformatter(date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
    }
    function myparser(s) {
        if (!s)
            return new Date();
        var ss = (s.split('-'));
        var y = parseInt(ss[0], 10);
        var m = parseInt(ss[1], 10);
        var d = parseInt(ss[2], 10);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
            return new Date(y, m - 1, d);
        } else {
            return new Date();
        }
    }
</script>
</div><!-- form -->